﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common;

namespace School.UserCentents
{
    public partial class MyPwd : UserCheckPower
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (new BLL.Users().GetModel(LoginUserId).UserTypeID <= 3)
            {
                Panel p1 = (Panel)Master.FindControl("Panel1");
                Panel p2 = (Panel)Master.FindControl("Panel2");
                Panel p3 = (Panel)Master.FindControl("Panel3");
                Panel p4 = (Panel)Master.FindControl("Panel4");
                p2.CssClass = "sldmenuoff";
                p1.CssClass = "sldmenuon0";
                p4.CssClass = "sld1";
                p3.CssClass = "sld0";
                p4.Attributes.Add("style", "display: none");
                p3.Attributes.Add("style", "");
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Model.Users user = new BLL.Users().GetModel(LoginUserId);
            string strpwd = Encryption.GetMD5(oldpwd.Value.Trim());
            string str = Encryption.GetMD5(newpwd1.Value.Trim());
            if (user.MembePassWord != strpwd)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "a", "<script>alert('原密码不正确！');</script>", false);
                return;
            }
            else
            {
                user.MembePassWord = str;
                new BLL.Users().Update(user);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "a", "<script>alert('修改密码成功！');</script>", false);
            }
        }
    }
}